from django.contrib.auth.models import AbstractUser
from django.db import models

class Cat(models.Model):
    catid = models.AutoField(primary_key=True, db_column='catid')
    cname = models.CharField(max_length=100)
    month = models.IntegerField()
    cgender = models.CharField(max_length=100)
    status = models.CharField(max_length=50)
    siteid = models.IntegerField()
    description = models.CharField(max_length=100)

    class Meta:
        managed = False
        db_table = 'cat'


class Person(models.Model):
    personid = models.AutoField(primary_key=True, db_column='personid')
    pname = models.CharField(max_length=100)
    gender = models.CharField(max_length=50)
    phone = models.IntegerField()
    birthday = models.DateField()
    area = models.CharField(max_length=100)
    donate_record = models.CharField(max_length=50)

    class Meta:
        managed = False
        db_table = 'person'


class Apply(models.Model):
    id = models.AutoField(primary_key=True, db_column='id')
    catid = models.IntegerField(db_column='catid')
    personid = models.IntegerField(db_column='personid')
    applytime = models.DateField()
    eco_check = models.CharField(max_length=50)
    env_check = models.CharField(max_length=50)

    class Meta:
        managed = False
        db_table = 'apply'

class Donate(models.Model):
    #donateid | dname  | sum  | time       | siteid
    donateid = models.AutoField(primary_key=True, db_column='donateid')
    dname = models.CharField(max_length=100)
    sum = models.DecimalField(max_digits=10, decimal_places=2)
    time = models.DateField()
    siteid = models.IntegerField()

    class Meta:
        managed = False
        db_table = 'donate'

class Site(models.Model):
    # siteid | sname        | sarea | address
    siteid = models.AutoField(primary_key=True)
    sname = models.CharField(max_length=100)
    sarea = models.CharField(max_length=100)
    address = models.CharField(max_length=200)

    class Meta:
        managed = False
        db_table = 'site'

class CustomUser(AbstractUser):
    phone = models.CharField(max_length=20, blank=True)

    class Meta:
        verbose_name = '用户'
        verbose_name_plural = '用户'

    def __str__(self):
        return self.username